def count(n):
    while True:
        yield n
        n += 1


c = count(0)
# c[10:20]  # 不可以切片
import itertools

for x in itertools.islice(c,10,20): # 迭代器切片
    print(x)